package com.yhhvip.rest.service;

import com.yhhvip.rest.config.GetApiUrl;
import com.yhhvip.rest.config.PostApiUrl;
import com.yhhvip.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

@Service
public class AdminService {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private GetApiUrl getApiUrl;
    @Autowired
    private PostApiUrl postApiUrl;

    public JsonResult adminLoginIn(String name,String password) {
        MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
        requestEntity.add("name", name);
        requestEntity.add("password", password);
        JsonResult result = restTemplate.postForObject(postApiUrl.getAdminLoginIn(), requestEntity, JsonResult.class);
        return result;
    }

}

